package com.wat;


import com.wat.aop.example2.Capitalist;
import com.wat.aop.example2.SadWorker;
import com.wat.aop.example2.Worker;
import com.wat.config.AppConfig;
import com.wat.domain.Order;
import com.wat.service.OrderService;
import org.springframework.aop.target.HotSwappableTargetSource;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.cglib.proxy.Proxy;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class Main {
	public static void main(String[] args) {

//		UserService target = new UserServiceImpl();
//		UserService instance = (UserService) new ProxyFactory(target).getProxyInstance();
//		instance.createUser("name");

		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.wat");



//		BeanLifeCycleTest();

//		BeanLifecycle beanLifecycle = (BeanLifecycle) context.getBean("beanLifecycle");



//		ConfigurableEnvironment environment = context.getEnvironment();


//		Car bmwCar = (Car) context.getBean("bmwCar");
//		Car audiCar = (Car) context.getBean("audiCar");
//		CarInstanceFactory carFactory = (CarInstanceFactory) context.getBean("carFactory");
//		Map map = carFactory.getMap();
//		Car car4 = (Car) context.getBean("car4");
//		Car car6 = (Car) context.getBean("car6");
//		System.out.println(car4);
//		System.out.println(car6);


/*
		// 获取 AOP 代理
		UserService userService = (UserService) context.getBean("userServiceImpl");
		userService.createUser("wat");
		userService.queryUser();

		OrderService orderService = context.getBean(OrderService.class);
		orderService.createOrder("wat", "随便买点什么");
		orderService.queryOrder("wat");*/




//		MessageService messageService = context.getBean(MessageService.class);
//		DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)context.getAutowireCapableBeanFactory();
		
//		String message = messageService.getMessage();
//		System.out.println("msg:" + message);

//		User bean = (User) context.getBean("user");
//		Object beanObj = context.getBean("&user");
	}




}
